<!DOCTYPE html>
<html lang="zh-CN" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layout/default" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <script th:src="@{/assets/scripts/addEmail.js}"></script>
    <link th:href="@{/assets/css/addEmail.css}" rel="stylesheet" type="text/css"/>
    <title>
        邮件服务器配置
    </title>
    <script>
        $(document).ready(function () {
            addEmail.init();
        })
    </script>
</head>
<body>
<div layout:fragment="content" th:remove="tag">
    <input type="hidden" th:value="${emailInfo.id}" id="emailInfoId">
    <input type="hidden" th:value="@{/email/validateEmail}" id="validateEmail">
    <input type="hidden" th:value="@{/email}" id="email">

    <div th:replace="fragments/tool :: tipMessage (type='',content=${message})" th:remove="tag"></div>
    <div class="row">
        <div class="col-md-12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <ul class="page-breadcrumb breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a th:href="@{/}">首页</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a href="#">配置管理</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a th:href="@{/email}">邮件服务器管理</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li><a href="#">
                    邮件服务器配置</a></li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>

    <div class="row profile">
        <div class="col-md-10 content-center">
            <!--BEGIN TABS-->
            <div class="tab-content">
                <div class="tab-pane active" id="user_tab_1_2">
                    <div class="portlet box blue">
                        <div class="portlet-body form">
                            <!-- BEGIN FORM-->
                            <form id="emailEditForm" class="form-horizontal"
                                  th:object="${emailInfo}"
                                  th:action="@{${emailInfo.id} != null ? '/email/update' : '/email/create' }"
                                  method="post">
                                <input type="hidden" th:field="*{id}"/>

                                <div class="form-body centent-color">
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">所属机构<span
                                                class="required">*</span></label>

                                        <div class="col-md-4">
                                            <div th:replace="fragments/tool :: treeSelect (id='company',name='company.id', labelName='company.name', nameVal=${emailInfo.company.id},labelVal=${emailInfo.company.name}, cssClass='required', placeholder='', dialogTitle='公司', remoteUrl='/sys/office/treeData?type=1', always=true)"></div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">邮件帐号<span
                                                class="required">*</span></label>

                                        <div class="col-md-3">
                                            <input type="text" class="form-control required"
                                                   th:field="*{email}" id="emailAccount"
                                                   maxlength="64" title="邮件帐号"/>
                                        </div>

                                        <label class="col-md-3 control-label">邮件密码<span
                                                class="required">*</span></label>

                                        <div class="col-md-3">
                                            <input type="text" class="form-control required" id="emailPassword"
                                                   th:value="${emailInfo.emailPassword}" name="emailPassword"
                                                   maxlength="32" title="邮件密码"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">服务器端口<span
                                                class="required">*</span></label>

                                        <div class="col-md-3">
                                            <input type="text" class="form-control required"
                                                   th:field="*{port}" id="sysCount"
                                                   onkeyup="this.value=this.value.replace(/\D/g,'')"
                                                   onafterpaste="this.value=this.value.replace(/\D/g,'')"
                                                   maxlength="5" title="服务器端口"/>
                                        </div>

                                        <div class="col-md-1">
                                            <input type="checkbox" class="form-control"
                                                   th:checked="*{openSSL}"
                                                   name="openSSL" id="openSSL"/>
                                            <label>SSL</label>
                                        </div>

                                        <label class="col-md-2 control-label">服务器地址<span
                                                class="required">*</span></label>

                                        <div class="col-md-3">
                                            <input type="text" class="form-control required"
                                                   th:field="*{serversAddress}"
                                                   maxlength="200" title="服务器地址"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">邮箱主题</label>

                                        <div class="col-md-9">
                                            <input type="text" class="form-control email"
                                                   th:name="emailTheme" maxlength="500"
                                                   th:value="${emailInfo.emailTheme} == null ? '升级成为开发者！' : *{emailTheme}"
                                                   title="邮箱主题"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">邮件内容
                                            <span class="required">*</span></label>

                                        <div class="col-md-9">
                                            <textarea rows="3" th:field="*{emailContent}"
                                                      style="resize:none" maxlength="2000"
                                                      th:text="*{emailContent} == null ? '您好，欢迎使用【宁云身份认证平台】！
您将完成账号与设备绑定：使用宁云扫描页面中的QR，完成绑定！' : *{emailContent}"
                                                      class="form-control" title="邮件内容"></textarea>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-2 control-label">邮件备注</label>

                                        <div class="col-md-9">
                                            <input type="text" class="form-control required"
                                                   th:name="emailRemarks"
                                                   th:value="${emailInfo.emailRemarks} == null ? 'QR码只能使用一次，限时为72小时。如有任何问题，请联系管理员！' : *{emailRemarks}"
                                                   maxlength="100" title="邮件备注"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-actions fluid">
                                    <div class="col-md-offset-6 col-md-6">
                                        <div class="col-md-5" style="margin-top: -2px;">
                                            <input type="checkbox" class="form-control"
                                                   th:checked="*{defaultEmail}"
                                                   name="defaultEmail" id="defaultEmail"/>
                                            <label>设置为默认邮件</label>
                                        </div>
                                        <button type="button" class="btn default" id="gotoEmail">返 回</button>
                                        <button type="button" class="btn green" id="verifyEmailBt">验证邮箱</button>
                                        <button type="button" class="btn blue" id="updateEmailBt">保 存</button>
                                    </div>
                                </div>
                            </form>
                            <!-- END FORM-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
